package com.permission.util;

import com.permission.constant.ResultEnum;
import com.permission.vo.ResultVo;

/**
 * Created by Administrator on 2018/4/2
 */
public class ResultVoUtil {

    public static ResultVo<Object> success(Object object) {
        ResultVo<Object> resultVo = new ResultVo<>();
        resultVo.setCode(ResultEnum.SUCCESS.getCode());
        resultVo.setMsg(ResultEnum.SUCCESS.getMsg());
        resultVo.setData(object);
        return resultVo;
    }

    public static ResultVo<Object> success() {
        return success(null);
    }

    public static ResultVo error(Integer code, String msg) {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(code);
        resultVo.setMsg(msg);
        return resultVo;
    }

    public static ResultVo errorSystem(String msg) {
        return error(ResultEnum.SYSTEM_ERROR.getCode(), msg);
    }
}
